//
//  BaseTableViewController.swift
//  sinaWeiBo
//
//  Created by weixq on 15/7/30.
//  Copyright © 2015年 weixq. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorloginViewDelegate {
   
    /// 定义用户是否登录
    let userLogon = UserAccount.userLogon

    var visitorView: VisitorLoginView?

    /// 定义view视图
    override func loadView(){
        userLogon ? super.loadView() : setUpVisitorView()

    }
    
    /// 定义visitorview
    private func setUpVisitorView(){
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
         view = visitorView
        
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
    
    }
    
    func visitorLoginViewWillLogin() {
        let nv = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nv, animated: true, completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
    }
    
}
